package MR_process;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class Bean1 implements WritableComparable<Bean1>{
    private String word,doc_id;
    private long count;

    @Override
    public String toString() {
        return word + "\t"+ doc_id +"\t"+ count;
    }


    public Bean1(String word, String doc_id, long count) {
        this.word = word;
        this.doc_id = doc_id;
        this.count = count;
    }


    public String getWord() {
        return word;
    }


    public void setWord(String word) {
        this.word = word;
    }


    public String getDoc_id() {
        return doc_id;
    }


    public void setDoc_id(String doc_id) {
        this.doc_id = doc_id;
    }


    public long getCount() {
        return count;
    }


    public void setCount(long count) {
        this.count = count;
    }


    @Override
    public void write(DataOutput out) throws IOException {
        //注意数据类型
        out.writeUTF(word);
        out.writeUTF(doc_id);
        out.writeLong(count);
    }
    @Override
    public void readFields(DataInput in) throws IOException {
        //注意和write的顺序保持对应一致
        this.word=in.readUTF();
        this.doc_id=in.readUTF();
        this.count=in.readLong();
    }
    @Override
    public int compareTo(Bean1 o) {
        if(word.equals(o.word)&&(doc_id.equals(o.doc_id))&&count==o.count) return 0;
        return 1;
    }

    public Bean1(){}

}
